<?php
class Sectores_model extends CI_Model {
    
    public function __construct() {
        $this->load->database();
    }
    
    public function get_sectores() {
        $query = $this->db->query("SELECT *
                                    FROM
                                        sectores
                                    ORDER BY 
                                        sector");
        return $query->result_array();
    }
    
    public function get_sector($idsector) {
        $query = $this->db->query("SELECT *
                                    FROM
                                        sectores
                                    WHERE
                                        idsector = $idsector");
        return $query->row_array();
    }
    
    public function update($datos, $id) {
        $idsector = array(
            'idsector' => $id
        );
        
        $this->db->update('sectores', $datos, $idsector);
    }
    
    public function set_sector($datos) {
        $this->db->insert('sectores', $datos);
    }
}
?>
